//
//  receiveFirCirNewComment.m
//  tcpoctest
//
//  Created by apple on 13-5-2.
//  Copyright (c) 2013年 gump. All rights reserved.
//

#import "receiveFirCirNewComment.h"
#import "FirCirCommentInfo.h"
#import "FirCirLocalInfo.h"
#import "FirCirLocalResourceDataSource.h"
#import "FirendCirLocalPathdb.h"

@implementation receiveFirCirNewComment

-(void)processreceive
{
    //收到 74char(1),14char(1),用户名长度char(1), 用户名char(x),动态id字串长度char(1),
    //动态id字串char(x),发言人用户名长度char(1),发言人用户名char(x),接收人用户名长度char(1),
    //接收人用户名char(x),时间长度char(1),时间char(x),区分值char(1)1文字\2语音,
    //评论ID长度char(1),评论IDchar(x),二进制数据长度int，二进制数据char(x)
    //备注：如果区分值是语音 二进制数据是URL
    
    
    FirCirCommentInfo *fccinfo = [[FirCirCommentInfo alloc] init];
    fccinfo.mail = [logicsb ReadUnencodeString];
    fccinfo.newsID = [logicsb ReadUnencodeString];
    fccinfo.speaker = [logicsb ReadUnencodeString];
    fccinfo.speakto = [logicsb ReadUnencodeString];
    fccinfo.strtime = [logicsb ReadUnencodeString];
    fccinfo.stIndex = [logicsb ReadChar];
    fccinfo.commentID = [logicsb ReadUnencodeString];
    fccinfo.content = [logicsb ReadUnencodeString];
    
    if (fccinfo.stIndex == FCG_ONE_SOUND) {
        FirCirLocalInfo *fclinfo = [[FirCirLocalInfo alloc] init];
        fclinfo.resourceID = fccinfo.commentID;
        fclinfo.url = fccinfo.content;
        
        [[DataControl shareControl].fcLocalRecDS AddLocalRs:fclinfo];
        [[DataBaseCtrol shareControl].fircirlocaldatabase insertLocalPath:fclinfo];
    }
    
    [[DataControl shareControl] AddComment:fccinfo];
    
    [[DataControl shareControl].UICommendDS addUICommand:UC_REFRESHCURVIEW];
    
    [self ShowLog];
}

@end
